package com.agileboot.domain.airport.reform.model;

import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.airport.reform.db.SirReformMainEntity;
import com.agileboot.domain.airport.reform.db.SirReformMainService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class ReformMainModelFactory {

    @Qualifier("sirReformMainServiceImpl")
    private final SirReformMainService reformService;

    public ReformMainModel loadById(Long id) {
        SirReformMainEntity entity = reformService.getById(id);
        if (entity == null) {
            throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, id, "整改通知书");
        }
        return new ReformMainModel(entity, reformService);
    }

    public ReformMainModel create() {
        return new ReformMainModel(reformService);
    }
}
